// package main
// import(
// 	"fmt"
// 	"github.com/gin-gonic/gin"
// 	"net/http"
// )

// func main(){
// 	r:=gin.Default()
// 	r.LoadHTMLGlob("templates/*")
// 	r.GET("/",func(c* gin.Context){
// 		c.JSON(http.StatusOK,map[string]interface{}{
// 			"name":"zhangsan",
// 			"age":78,
// 			"gender":"male",
// 		})
// 	})
// 	r.GET("/news",func(c *gin.Context){
// 		c.HTML(http.StatusOK,"index.html",gin.H{
// 			"title":"这是一个新闻页面",
// 		})
// 	})
// 	r.GET("/goods",func(c *gin.Context){
// 		c.HTML(http.StatusOK,"goods.html",gin.H{
// 			"title":"这是一个商品页面",
// 		})
// 	})
// 	r.Run()
// 	fmt.Println("hello world")
// }

package main
import (
	//"fmt"
	"github.com/gin-gonic/gin"
	"net/http"
)
type Article struct{
	Title string
	Content string
}
func main(){
	r:=gin.Default()
	r.LoadHTMLGlob("templates/**/*")
	r.GET("/index",func(c *gin.Context){
		c.HTML(http.StatusOK,"default/index.html",map[string]interface{}{
			"title":"this is 前台首页",
		})
	})
	r.GET("/news",func(c *gin.Context){
		news:=&Article{
			Title:"自然",
			Content: "人与自然和谐相处",
		}
		c.HTML(http.StatusOK,"default/news.html",gin.H{
			"title":"这是前台新闻页面",
			"news":news,
		})
	})
	r.GET("/demin/index",func(c* gin.Context){
		c.HTML(http.StatusOK,"demin/index.html",gin.H{
			"title":"这是后台首页",
		})
	})
	r.GET("/demin/news",func(c *gin.Context){
		a:=&Article{
			Title:"阶级斗争",
			Content:"新的斗争又开始了，人民万岁！！！",
		}
		c.HTML(http.StatusOK,"demin/news.html",map[string]interface{}{
			"title":"这是后台新闻页面",
			"news":a,
			"score":88,
			"slice":[]string{"吃饭","睡觉","写代码"},
			"sliceinterface":[]interface{}{
				&Article{
					Title:"标题1111",
					Content:"内容111",
				},
				&Article{
					Title:"标题222",
					Content:"内容222",
				},
			},
			"slicegtest":[]string{},
			"msg":&Article{
				Title:"新闻标题",
				Content:"新闻内容",
			},
		})
	})


	r.Run()
}